package com.gem.day12.homework;

import java.util.*;
import java.util.Map.Entry;

public class Exercise2 {
	public static void main(String[] args) {
		Map<String, Double> map = new HashMap<>();
		map.put("小明", 80.0);
		map.put("小红", 70.0);
		map.put("小花", 75.0);
		map.put("小胖", 95.0);
		map.put("小雅", 65.0);
		Set<Entry<String, Double>> entrySet = map.entrySet();
		List<Entry<String, Double>> list = new ArrayList<>();
		for (Object o : entrySet) {
			Entry<String, Double> e = (Entry<String, Double>) o;
			list.add(e);
		}
		Collections.sort(list, (o1, o2) -> {
			if (o1 instanceof Entry && o2 instanceof Entry) {
				Entry e1 = (Entry) o1;
				Entry e2 = (Entry) o2;
				return ((Double) e2.getValue()).compareTo((Double) e1.getValue());
			} else {
				return 0;
			}
		});
		for (int i = 0; i < 3; i++) {
			System.out.println(list.get(i));
		}
	}
}
